import coursesolutions.courseparser.*;
import hw3.*;
import hw4.*;
import java_cup.runtime.Symbol;
import java.util.Vector;

import common.Listing;
import common.openFile;

public class Main {
   public static void main(String args[]) throws Exception {
      
      new Listing(System.err);
      CourseParser parser = new CourseParser(new CourseScanner(args.length == 0 ? new openFile("") : new openFile(args[0])));


      AbstractNode root = (AbstractNode) parser.parse().value;

      System.err.println("\nRaw AST (with node numbers)");
      root.accept(new DumpNodeVisitor(System.err));

      System.err.println("Building Symbol table");
      root.accept(SymtabVisitor.getVisitor());

      System.err.println("Type Setting pass");
      root.accept(CodeGenVisitor.getTypeSetVisitor());

      System.err.println("\nRaw AST (with node numbers)");
      root.accept(new DumpNodeVisitor(System.err));

      System.err.println("Code Generation");
      root.accept(CodeGenVisitor.getCodeGenVisitor());
   }


}
